/*
Source : https://leetcode.com/problems/sum-of-two-integers/
Author : nflush@outlook.com
Date   : 2016-07-14
*/

/*
371. Sum of Two Integers
 ?  

Question Editorial Solution  
 My Submissions 




?Total Accepted: 12557
?Total Submissions: 24259
?Difficulty: Easy



Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -.

Example:
 Given a = 1 and b = 2, return 3. 

Credits:
Special thanks to @fujiaozhu for adding this problem and creating all test cases.



Subscribe to see which companies asked this question
*/
class Solution {
public:
    int getSum(int a, int b) {
        int c = a ^b;
        int d = a &b;
        if (d) return getSum(c, d<<1);
        return c;
    }
};
